package cn.edu.cqu.bysj.wm.gui.model;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

import org.neo4j.graphdb.Direction;

import cn.edu.cqu.bysj.wm.ago.lp.LP;
import cn.edu.cqu.bysj.wm.def.ConstDef.AlgorithmType;
import cn.edu.cqu.bysj.wm.def.ConstDef.ConfigType;
import cn.edu.cqu.bysj.wm.def.ConstDef.KeyNodeType;
import cn.edu.cqu.bysj.wm.def.Weight;

public class AlgorithmConfig {

	private ConfigType type;
	private Direction direction = Direction.BOTH;
	private Weight weight = Weight.UNWEIGHTED;
	String filePath = "";
	
	// 用在tab的标题中
	private String title;
	
	// lp算法运行次数
	private int time = 1;

	// LP还是GN,Fagin还是Skyline
	private AlgorithmType algrithismType;

	// 关键节点类型(局部还是全局)
	private KeyNodeType keyNodeType;
	
	// top-k值(fagin中)
	private int topK;
	
	// 社区内关键节点比例(fagin中)
	private double percent;
	
	// lp结果，用来做关键节点发现
	private LP lp;
	
	// 关键节点指标选择
	private int[] flag;
	
	public AlgorithmConfig(int i) {
		this.setTitle(" " + i);
		this.type = ConfigType.SQ;
	}

	public AlgorithmConfig(String title, Direction haveDirection,
			Weight haveWeight) {
		this.setTitle(title);
		this.setDirection(haveDirection);
		this.setWeight(haveWeight);
		this.type = ConfigType.SQ;
	}
	public Map<String, String> getSuperConfig() {
		Map<String, String> maps = new HashMap<String, String>();
		Field[] fields = this.getClass().getDeclaredFields();
		for (Field field : fields) {
			try {
				if (field.get(this) != null && !field.getName().startsWith("$")) {
					maps.put(field.getName(), field.get(this).toString());
				}
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
		}
		return maps;
	}

	public int[] getFlag() {
		return flag;
	}

	public void setFlag(int[] flag) {
		this.flag = flag;
	}

	public int getTopK() {
		return topK;
	}

	public void setTopK(int topK) {
		this.topK = topK;
	}

	public double getPercent() {
		return percent;
	}

	public void setPercent(double percent) {
		this.percent = percent;
	}

	public LP getLp() {
		return lp;
	}

	public void setLp(LP lp) {
		this.lp = lp;
	}

	public KeyNodeType getKeyNodeType() {
		return keyNodeType;
	}

	public void setKeyNodeType(KeyNodeType keyNodeType) {
		this.keyNodeType = keyNodeType;
	}

	public String getFilePath() {
		return filePath;
	}

	public void setFielPath(String fielPath) {
		this.filePath = fielPath;
	}

	public int getTime() {
		return time;
	}

	public void setTime(int time) {
		this.time = time;
	}

	public Direction getDirection() {
		return direction;
	}

	public void setDirection(Direction direction) {
		this.direction = direction;
	}

	public Weight getWeight() {
		return weight;
	}

	public void setWeight(Weight weight) {
		this.weight = weight;
	}

	public void next() {
		this.type = (ConfigType.JD);
	}

	public ConfigType getType() {
		return type;
	}

	public AlgorithmType getAlgorithmType() {
		return algrithismType;
	}

	public void setAlgorithmType(AlgorithmType algrithismType) {
		this.algrithismType = algrithismType;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

}
